package controllersx;

import lombok.SneakyThrows;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Author wuchao66
 * @Date 2022/7/7 10:20
 * @Version 1.0
 */
@WebServlet(name = "ServletReturn",urlPatterns = "/ServletReturn")
public class ServletReturn extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//乱码问题
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        //out对象
        PrintWriter out = response.getWriter();//文件流
        response.sendRedirect(request.getContextPath()+"/t163demo/load.jsp");
        //刷新缓存区 关闭
        out.flush();
        out.close();
    }
    @SneakyThrows
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //乱码问题
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        //out对象
        PrintWriter out = response.getWriter();//文件流

        response.sendRedirect(request.getContextPath()+"/t163demo/load.jsp");


        out.flush();
        out.close();

    }

}
